home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / dev / basic / RIBlitzLibs.lha / riblitzlibs / docs / RISortLib.doc < prev    next >
Encoding:
Text File  |  1995-01-29  |  3.1 KB  |  94 lines

  1. -----------------------------------------------------------------------------
  2. ----               RI String Sort Library V1.3 (C)94/95                  ----
  3. -----------------------------------------------------------------------------
  4.  
  5.                         Written By Stephen McNamara
  6.                         ©94/95 Leading Edge Software
  7.  
  8.  
  9. This library allows you to sort a linked list of items.  It works
  10. only with linked lists, and at present can only sort items into alphabetical
  11. order based on a string in the item.
  12. The sorting routine used in this library is very simple and crude.  This
  13. library should not be used to sort in speed critical situations due to the
  14. inefficiency of the sorting method.  The library will, though, be fast
  15. enough for most situations.
  16.  
  17.  
  18. Command list:
  19.         StringSort linkedlist(),sizeof.type[,offset]
  20.         =ListBase (linkedlist)
  21.         StringSortItem linkedlist(),sizeof.type[,offset]
  22.         StringSortDir direction
  23.  
  24.  
  25. Statement: StringSort
  26. ------------------------------------------------------------------------
  27. Modes : Amiga/Blitz
  28. Syntax: StringSort linkedlist(),sizeof.type[,offset]
  29.  
  30. This is the basic sort command.  Its first parameter is a linked list, the
  31. second is the sizeof each item in this list (e.g. the size of they type or
  32. newtype that each item is).  The optional offset parameter allows you to
  33. specify an offset into each item, this offset should be the offset for the
  34. string you want to sort by.  If the offset parameter is missing, an offset
  35. of 0 will be assumed.
  36.  
  37. This command sorts the whole of the linked list, starting from the very
  38. first item.
  39.  
  40. Example:
  41.  
  42.         Newtype.listitem
  43.             pad.w
  44.             text$
  45.         End Newtype
  46.  
  47.         Dim List myitems.listitem(10)
  48.  
  49.         AddItem myitems() : myitems()\text="Hello"
  50.         AddItem myitems() : myitems()\text="World"
  51.  
  52.         ;Sort list myitems(), string is offset 2 from start of type
  53.         StringSort myitems(),SizeOf.listitem,2
  54.  
  55.         ResetList myitems()
  56.         While NextItem(myitems())
  57.             NPrint myitems()\text
  58.         Wend
  59.  
  60.         MouseWait
  61.         End
  62.  
  63.  
  64. Function: ListBase
  65. ------------------------------------------------------------------------
  66. Modes : Amiga/Blitz
  67. Syntax: ad.l=ListBase(linkedlist())
  68.  
  69. This command returns the base address of the linked list supplied.  This
  70. address holds data for the linked list, and pointers to the first item and
  71. current item in the list.  This command will not be of any use to most
  72. people, rather it is included for debugging purposes.
  73.  
  74.  
  75. Statement: StringSortItem
  76. ------------------------------------------------------------------------
  77. Modes : Amiga/Blitz
  78. Syntax: StringSortItem linkedlist(),sizeof.type[,offset]
  79.  
  80. This is basically the same command as StringSort except that this command
  81. sorts the linked list from the *current* list item rather than the first
  82. list item.  Thus it can be used to only sort a part of a list.  Apart from
  83. this the command is the same as StringSort.
  84.  
  85.  
  86. Statement: StringSortDir
  87. ------------------------------------------------------------------------
  88. Modes : Amiga/Blitz
  89. Syntax: StringSortDir direction
  90.  
  91. Set the direction of sorting.  A direction of zero causes strings to be
  92. sorted into ascending order (smallest to largest), non-zero selects
  93. descending order (largest to smallest).
  94.